Feature: permit (most) reserved attributes names as property names#582
Open
dgkf wants to merge 2 commits intoRConsortium:mainfrom
Open
Feature: permit (most) reserved attributes names as property names#582dgkf wants to merge 2 commits intoRConsortium:mainfrom
dgkf wants to merge 2 commits intoRConsortium:mainfrom
Conversation
dgkf
commented
Nov 26, 2025
Comment on lines
196
to
199
| prop <- function(object, name) { | ||
| .Call(prop_, object, name) | ||
| attr_name <- remap_reserved_names(name) | ||
| .Call(prop_, object, name, attr_name) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This is the primary change. attr_name was added as an additional parameter to prop_ (and prop_set_).
It only differs from name in cases when there's a clash with a reserved name, in which case it gets mangled, such as .__S7_prop_names__.
Attributes get remapped at this point so that they keep their user-facing name for all other purposes.
30bf0fa to
2c7b645
Compare
2c7b645 to
b9f6cb8
Compare
dgkf
commented
Nov 26, 2025
Comment on lines
289
to
295
| attrs <- c( | ||
| list(class = class_dispatch(class), S7_class = class), | ||
| args[!has_setter], | ||
| with_remap_reserved_names(args[!has_setter]), | ||
| attributes(object) | ||
| ) | ||
| attrs <- attrs[!duplicated(names(attrs))] | ||
| attributes(object) <- attrs |
Contributor
Author
There was a problem hiding this comment.
When arguments are passed through new_object() they are assigned to attribute values directly, so they go through the same remapping for reserved names here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #579
propandprop<-, I've remapped attribute names for use inRf_setAttribinprop_andprop_set_respectively.new_class, remaps attributes where they're assigned directly...as it raises a parse error when trying to use it viaobj@..., but this is an R syntax error and it would still work viaprop(obj, "..."). I'd probably lean toward even permitting this, but it seemed explicitly undesirable in Defining a property named "..." should not be allowed #442air, let me know if you'd like whitespace changes reverted.